from collections import deque
n, m = map(int, input().split())
door = {}
for _ in range(m):   # 利用字典来存储传送门
    x1, y1, x2, y2 = map(int, input().split())
    door.setdefault((x1, y1), []).append((x2, y2))
    door.setdefault((x2, y2), []).append((x1, y1))
# 初始化每个点到终点举例为无穷大
dis = [[float('inf')] * (n + 1) for _ in range(n + 1)]
dis[n][n] = 0
q = deque()
q.append((n, n)) # 以终点为起点，开始bfs

while q:
    x, y = q.popleft()
    now_dis = dis[x][y]
    # 遍历四个方向
    for i, j in [(0, 1), (0, -1), (1, 0), (-1, 0)]:
        nx, ny = x + i, y + j
        if 1 <= nx <= n and 1 <= ny <= n and now_dis + 1 < dis[nx][ny]:
            dis[nx][ny] = now_dis + 1
            q.append((nx, ny))
    # 判断传送门
    if (x, y) in door:
        for tx, ty in door[(x, y)]:
            if dis[tx][ty] > now_dis + 1:
                dis[tx][ty] = now_dis + 1
                q.append((tx, ty))

total = sum(dis[i][j] for i in range(1, n + 1) for j in range(1, n + 1))
print(f"{total/n**2:.2f}")
